﻿<%@ Page Title="" Language="C#" MasterPageFile="~/App_form/Menu/dao_tao.master" AutoEventWireup="true" CodeFile="nhapdiem.aspx.cs" Inherits="App_form_Daotao_nhapdiem" %>

<%@ Register TagPrefix="Control" TagName="menu_phai" Src="~/App_ctr/Admin/menu_phai.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div style="width: 100%">
        <div style="width: 20%; float: left;">
            <Control:menu_phai runat="server" ID="menuphai" />
        </div>
        <div style="width: 79.4%; float: right;">
            <div style="background-image: url(../../CSS/images/ui-bg_glass_75_e6e6e6_1x400.png); font-weight: bold; height: 30px; border: 1px solid #d3d3d3; margin-top: 4px; text-align: center; padding-top: 8px; text-transform: uppercase;">
                Nhập điểm
            </div>
            <div style="margin-top: 2px;">
                <div style="display: table; margin: 0 auto; width: 100%; border: 1px solid #d3d3d3; font-size: 16px;">
                    <div id="ndung_ct" class="clearfix">
                        <div style="width: 100%; float: left; padding: 30px;">
                            <div style="float: left; width: 8%;">
                                <label>
                                    Loại  :
                                </label>
                            </div>
                            <div style="float: left; width: 60%">
                                <Lib:drop runat="server" ID="loai" DataTextField="TEN" DataValueField="MA" Width="120px" Height="23px" onClientChange="P_NHAP_CHON()"></Lib:drop>
                            </div>
                            <div style="width: 100%; height: 6px; float: left;"></div>
                            <div style="float: left; width: 8%;">
                                <label>
                                    Năm học  :
                                </label>
                            </div>
                            <div style="float: left; width: 14%">
                                <Lib:drop runat="server" ID="namhoc" DataTextField="TEN" DataValueField="MA" Width="120px" Height="23px" onClientChange="P_LOP_LKE()"></Lib:drop>
                            </div>
                            <div style="float: left; width: 6%;">
                                <label>
                                    Học kỳ :
                                </label>
                            </div>
                            <div style="float: left; width: 16%">
                                <Lib:drop runat="server" ID="hocky" DataTextField="TEN" DataValueField="MA" Width="160px" Height="23px" onClientChange="P_LOP_LKE()"></Lib:drop>
                            </div>
                            <div style="width: 100%; height: 6px; float: left;"></div>

                            <div style="float: left; width: 8%;">
                                <label>
                                    Lớp:
                                </label>
                            </div>
                            <div style="float: left; width: 14%">
                                <Lib:drop runat="server" ID="lop" DataTextField="TEN" DataValueField="ID" Width="120px" Height="23px" onClientChange="P_MON_PC_LKE()"></Lib:drop>
                            </div>
                            <div style="float: left; width: 6%;">
                                <label>
                                    Môn:
                                </label>
                            </div>
                            <div id="mon_kt" style="float: left; width: 16%">
                                <Lib:drop runat="server" ID="mon" DataTextField="TEN" DataValueField="MA" Width="160px" Height="23px"></Lib:drop>
                            </div>
                            <div style="float: left; width: 6%;">
                                <label>
                                    Loại KT:
                                </label>
                            </div>
                            <div id="loai_kt" style="float: left; width: 16%">
                                <Lib:drop runat="server" ID="loaikt" DataTextField="TEN" DataValueField="ID" Width="151px" Height="23px"></Lib:drop>
                            </div>
                            <div style="float: left; width: 20%">
                                <Lib:Button runat="server" ID="tim" Icon="FIND" Text="Tìm" Width="100px" onClientClick="P_NH_TIM()"></Lib:Button>
                                <Lib:Button runat="server" ID="add" Icon="ADD" Text="Thêm mới" Width="100px" onClientClick="P_DIEM_NH()"></Lib:Button>
                            </div>
                            <div style="width: 100%; height: 6px; float: left;"></div>
                             <div style="float: right; width: 99%">
                                <Lib:Button runat="server" ID="Button1" Icon="EXCEL" Text="Excel" Width="100px" onClientClick="P_NH_EXPORT()"></Lib:Button>
                                <Lib:Button runat="server" ID="Button2" Icon="EXCEL" Text="Import" Width="100px" onClientClick="P_DIEM_IMPORT()"></Lib:Button>
                            </div>
                        </div>
                        <div style="width: 100%; float: left;">
                            <Lib:gridView runat="server" ID="diem" Width="1020" Height="380">
                                <Columns>
                                    <Lib:Column BaseColumn="lop" Name="Lớp" Width="300" />
                                    <Lib:Column BaseColumn="ma_sv" Name="Mã sv" Width="100" />
                                    <Lib:Column BaseColumn="ten" Name="Tên" Width="300" />
                                    <Lib:Column BaseColumn="noi_sinh" Name="Địa chỉ" Width="200" />
                                    <Lib:Column BaseColumn="diem" Name="Điểm" Width="100" EditControlType="TextBox" DataType="Number" Dec="1" />
                                </Columns>
                                <Pager>
                                    <Lib:Pager PageSize="15" />
                                </Pager>
                            </Lib:gridView>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <asp:HiddenField ID="kthuoc" runat="server" Value="0,0" />
    <script>
        //
        function P_NHAP_CHON()
        {
            var loai = $("#<%=loai.ClientID%>").val();
            if(loai=="RL")
            {
                $get("loai_kt").disabled = true;
                $get("mon_kt").disabled = true;
            }
            else
            {
                $get("loai_kt").disabled = false;
                $get("mon_kt").disabled = false;
            }
        }
        function P_LOP_LKE()
        {
            var b_hk = $("#<%=hocky.ClientID%>").val(), b_nam = $("#<%=namhoc.ClientID%>").val();
            wdt_ma.Fs_PC_DIEM_LOP_LKE(b_nam, b_hk, P_PCLOP_KQ, ErrorDb, ErrorTimeOut);
            return false;
        }
        function P_PCLOP_KQ(b_kq)
        {
            if (CheckError(b_kq)) {
                ShowError(b_kq);
                return;
            }
            GetDropByID("<%=lop.ClientID%>").dataBin(b_kq);
            P_MON_PC_LKE();
        }
        //TIM MÔN
        function P_MON_PC_LKE() {
            try {
                var b_hk = $("#<%=hocky.ClientID%>").val(), b_nam = $("#<%=namhoc.ClientID%>").val(), b_lop = $("#<%=lop.ClientID%>").val();
                wdt_ma.FDT_MON_PC_MON_LKE(b_hk, b_nam, b_lop, P_PC_MON_KQ, ErrorDb, ErrorTimeOut);
            }
            catch (err) {
                ShowError(err);
            }
        }

        function P_PC_MON_KQ(b_kq) {
            if (CheckError(b_kq)) {
                ShowError(b_kq);
                return;
            }
            GetDropByID("<%=mon.ClientID%>").dataBin(b_kq);
        }

        //TÌM
        function P_NH_TIM() {
            var b_hk = $("#<%=hocky.ClientID%>").val(), b_nam = $("#<%=namhoc.ClientID%>").val(), b_lop = $("#<%=lop.ClientID%>").val(),
                b_loai = $("#<%=loai.ClientID%>").val(), b_loai_kt = $("#<%=loaikt.ClientID%>").val(), b_mon = $("#<%=mon.ClientID%>").val();
            wdt_ma.FDT_DIEM_LKE(b_lop, b_mon, b_nam, b_hk, b_loai_kt, b_loai, P_DIEM_LKE_KQ, ErrorDb, ErrorTimeOut);
        }
        function P_DIEM_LKE_KQ(b_kq) {
            if (CheckError(b_kq)) {
                ShowError(b_kq);
                return;
            }
            var grid = GetGridByID("<%=diem.ClientID%>");
            grid.dataBin(b_kq);
        }

        //NHẬP
        function P_DIEM_NH()
        {
            var gridData = GetGridByID("<%=diem.ClientID%>").getData();
            var id_dk = new Array(), a_diem = new Array();

            var j = 0;
            for (var i = 0; i < gridData.length; i++)
            {
                if (gridData[i].ID != undefined && gridData[i].DIEM!="") {
                    id_dk[j] = gridData[i].ID;
                    a_diem[j] = gridData[i].DIEM;
                    j++;
                }
            }
            var b_loai = $("#<%=loai.ClientID%>").val(), b_loaikt = $("#<%=loaikt.ClientID%>").val();
            wdt_ma.FDT_DIEM_NH(b_loai, b_loaikt, id_dk, a_diem, P_DIEM_NH_KQ, ErrorDb, ErrorTimeOut);
            return false;
        }
        function P_DIEM_NH_KQ(b_kq)
        {
            if (CheckError(b_kq)) {
                ShowError(b_kq);
                return;
            }
            Msg.Show("Thông báo", "Lưu thành công", "info");
        }

        function P_NH_EXPORT()
        {
            var b_hk = $("#<%=hocky.ClientID%>").val(), b_nam = $("#<%=namhoc.ClientID%>").val(), b_lop = $("#<%=lop.ClientID%>").val(),
                b_loai = $("#<%=loai.ClientID%>").val(), b_loai_kt = $("#<%=loaikt.ClientID%>").val(), b_mon = $("#<%=mon.ClientID%>").val();
            var b_ten_lop = $("#<%=lop.ClientID%> option:selected").text(),
                b_ten_mon = $("#<%=mon.ClientID%> option:selected").text();
            wdt_ma.FDT_DIEM_LKE_EXCEL(b_lop, b_mon, b_nam, b_hk, b_loai_kt, b_loai, b_ten_lop, b_ten_mon, P_DIEM_LKE_EXCEL_KQ, ErrorDb, ErrorTimeOut);
        }
        function P_DIEM_LKE_EXCEL_KQ(b_kq) {
            if (CheckError(b_kq)) {
                ShowError(b_kq);
                return;
            }
            var tenf = '<%= this.ResolveUrl("~/Outputs/")%>';
            tenf = tenf + b_kq;
            window.location.assign(tenf);
            return false;
        }

        function P_DIEM_IMPORT()
        {
            var url = "<%=this.ResolveUrl("~/App_form/Import/importDiem.aspx")%>";
            OpenWindow(url, window.name );
        }

        function P_FILE()
        {
            //(object loai_diem, object nam_id, object mon_id, object hk_id, object ma_sv, object loai_kt)
            var b_hk = $("#<%=hocky.ClientID%>").val(), b_nam = $("#<%=namhoc.ClientID%>").val(), b_lop = $("#<%=lop.ClientID%>").val(),
               b_loai = $("#<%=loai.ClientID%>").val(), b_loai_kt = $("#<%=loaikt.ClientID%>").val(), b_mon = $("#<%=mon.ClientID%>").val();
            wdt_ma.FDT_DIEM_IMPORT_NH(b_loai, b_nam, b_mon, b_hk, b_lop, b_loai_kt, P_DIEM_IMPORT_EXCEL_KQ, ErrorDb, ErrorTimeOut);
            
        }
        function P_DIEM_IMPORT_EXCEL_KQ(b_kq)
        {
            if (CheckError(b_kq)) {
                ShowError(b_kq);
                return;
            }
            P_NH_TIM();
        }
    </script>
</asp:Content>

